<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class C_mkaryawan extends CI_Controller {
	public function __construct(){
		parent::__construct();
		$this->load->model('m_mkaryawan', '', TRUE);
	}
	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index(){
		if($this->auth->is_logged_in() == false){
			redirect('c=c_login','refresh');
		}
		$this->load->view('main/v_mkaryawan');
	}
	
	function mkaryawan_list(){
		$result=$this->m_mkaryawan->mkaryawan_list();
		echo $result;
	}
	
	//event handler action
	function get_action(){
		$task = $_POST['task'];
		switch($task){
			case "CREATE":
				$this->create();
				break;
			case "UPDATE":
				$this->update();
				break;
			default:
				echo "{failure:true}";
				break;
		}
	}
	
	function create(){
		$mkaryawan_nik=trim(@$_POST["mkaryawan_nik"]);
		$mkaryawan_nik=htmlentities($mkaryawan_nik,ENT_QUOTES);
		$mkaryawan_grade=trim(@$_POST["mkaryawan_grade"]);
		$mkaryawan_grade=htmlentities($mkaryawan_grade,ENT_QUOTES);
		$mkaryawan_kodeunit=trim(@$_POST["mkaryawan_kodeunit"]);
		$mkaryawan_kodeunit=htmlentities($mkaryawan_kodeunit,ENT_QUOTES);
		$mkaryawan_kodejab=trim(@$_POST["mkaryawan_kodejab"]);
		$mkaryawan_kodejab=htmlentities($mkaryawan_kodejab,ENT_QUOTES);
		$mkaryawan_tglrevisi=trim(@$_POST["mkaryawan_tglrevisi"]);
		$mkaryawan_tglrevisi=htmlentities($mkaryawan_tglrevisi,ENT_QUOTES);
		$mkaryawan_namakar=trim(@$_POST["mkaryawan_namakar"]);
		$mkaryawan_namakar=htmlentities($mkaryawan_namakar,ENT_QUOTES);
		
		$result=$this->m_mkaryawan->create($mkaryawan_nik, $mkaryawan_grade, $mkaryawan_kodeunit, $mkaryawan_kodejab, 
				$mkaryawan_tglrevisi, $mkaryawan_namakar);
		echo $result;
	}
	
	function update(){
		$mkaryawan_niklama=trim(@$_POST["mkaryawan_niklama"]);
		$mkaryawan_niklama=htmlentities($mkaryawan_niklama,ENT_QUOTES);
		$mkaryawan_nik=trim(@$_POST["mkaryawan_nik"]);
		$mkaryawan_nik=htmlentities($mkaryawan_nik,ENT_QUOTES);
		$mkaryawan_grade=trim(@$_POST["mkaryawan_grade"]);
		$mkaryawan_grade=htmlentities($mkaryawan_grade,ENT_QUOTES);
		$mkaryawan_kodeunit=trim(@$_POST["mkaryawan_kodeunit"]);
		$mkaryawan_kodeunit=htmlentities($mkaryawan_kodeunit,ENT_QUOTES);
		$mkaryawan_kodejab=trim(@$_POST["mkaryawan_kodejab"]);
		$mkaryawan_kodejab=htmlentities($mkaryawan_kodejab,ENT_QUOTES);
		$mkaryawan_tglrevisi=@$_POST["mkaryawan_tglrevisi"];
		$mkaryawan_tglrevisi=is_numeric($mkaryawan_tglrevisi)?$mkaryawan_tglrevisi:0;
		$mkaryawan_namakar=trim(@$_POST["mkaryawan_namakar"]);
		$mkaryawan_namakar=htmlentities($mkaryawan_namakar,ENT_QUOTES);
		
		$result=$this->m_mkaryawan->update($mkaryawan_niklama, $mkaryawan_nik, $mkaryawan_grade, $mkaryawan_kodeunit, $mkaryawan_kodejab, 
				$mkaryawan_tglrevisi, $mkaryawan_namakar);
		echo $result;
	}
	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */